package com.ccrfid.rmc6.service.personnel;

import com.ccrfid.rmc6.appconfig.exception.pojo.AppException;
import com.ccrfid.rmc6.entity.personnel.PersonnelEntity;
import com.ccrfid.rmc6.pojo.dto.sync.PrisonerCardDto;
import com.ccrfid.rmc6.pojo.dto.sync.SyncExternalDto;
import com.ccrfid.rmc6.pojo.dto.sync.SyncPrisonerDto;
import com.ccrfid.rmc6.pojo.dto.sync.SyncPoliceDto;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Caching;

import java.sql.Timestamp;
import java.util.List;

public interface SyncPrisonerService {

    Timestamp getUpdateTime();

    SyncPrisonerDto getPrisonerInfo(String personnelSn);

    void updatePrisonerInfo(String prisonId, SyncPrisonerDto prisonerDto) throws AppException;

    void updatePrisonerPhoto(String personnelSn, byte[] image) throws AppException;

    byte[] getPrisonerPhoto(String personnelSn);

    Boolean existPhoto(String personnelSn) throws AppException;

    void updatePrisonerInfoSelfBind(SyncPrisonerDto prisonerDto) throws AppException;

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updatePrisonerInfoSelfBindUpdateByPersonnelSn(SyncPrisonerDto prisonerDto);

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updatePrisonerInfoSelfBindUpdateByUnifoNo(SyncPrisonerDto prisonerDto);

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updatePrisonerInfoSelfBindCreate(SyncPrisonerDto prisonerDto);

    void updatePrisonerInfo3rdBind(SyncPrisonerDto prisonerDto);

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updatePrisonerInfo3rdBindCreate(SyncPrisonerDto prisonerDto);

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updatePrisonerInfo3rdBindUpdate(SyncPrisonerDto prisonerDto);

    List<PrisonerCardDto> getAllPrisonersWithCard();

    SyncPoliceDto getPoliceInfo(String personnelSn) throws AppException;

    Boolean updatePoliceInfo(String prisonId, SyncPoliceDto policeDto) throws AppException;

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updatePoliceInfoSelfBindCreate(SyncPoliceDto policeDto);

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updatePoliceInfoSelfBindUpdate(SyncPoliceDto policeDto);

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updatePoliceInfo3rdBindCreate(SyncPoliceDto policeDto);

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updatePoliceInfo3rdBindUpdate(SyncPoliceDto policeDto);

    SyncExternalDto getExternalPersonInfo(String personnelSn) throws AppException;

    Boolean updateExternalPersonInfo(String prisonId, SyncExternalDto externalDto) throws AppException;

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updateExternalPersonInfoSelfBindCreate(SyncExternalDto externalDto);

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updateExternalPersonInfoSelfBindUpdate(SyncExternalDto externalDto);

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updateExternalPersonInfo3rdBindCreate(SyncExternalDto externalDto);

    @Caching(
            put = {
                    @CachePut(value = "personnels", key = "#result.cardNumber", condition = "#result.cardNumber != null"),
                    @CachePut(value = "personnels2", key = "#result.id")
            })
    PersonnelEntity updateExternalPersonInfo3rdBindUpdate(SyncExternalDto externalDto);
}
